﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Supermarket.Dal;

namespace Supermarket.Bll
{
    public class MeasureManager
    {
        public static void CreateMeasure(string measureName, string measureCode)
        {
            if (measureName.Length < 50 && measureCode.Length < 10)
            {
                Measure measure = new Measure();
                measure.MeasureName = measureName;
                measure.MeasureCode = measureCode;
                MeasureDB.CreateMeasure(measure);
            }
        }

        public static List<Measure> GetAllMeasures()
        {
            List<Measure> measures = MeasureDB.GetAllMeasures();

            return measures;
        }

        public static void Update(int measureId, string measureName, string measureCode)
        {
            if (measureName.Length < 50 && measureCode.Length < 10)
            {
                Measure measure = new Measure();
                measure.MeasureId = measureId;
                measure.MeasureName = measureName;
                measure.MeasureCode = measureCode;
                MeasureDB.Update(measure);
            }
        }

        public static void Delete(int measureId)
        {
            MeasureDB.Delete(measureId);
        }
    }
}
